import request from '@/plugins/axios'

//租赁合同模块
export function fetchList(query) {
  return request({
    url: '/api/lessorcontract/page',
    method: 'get',
    params: query
  })
}


//租赁合同模块历史
export function fetchListHistory(query) {
    return request({
        url: '/api/lessorcontract/page-history',
        method: 'get',
        params: query
    })
}

export function getHisList(contractId){
    //alert(contractId);
    return request({
        url: '/api/lessorcontracthis/list/'+contractId,
        method: 'get'
    })
}

//续签记录，同一个parentId下
export function getRenewList(lessorcontractId) {
    return request({
        url: '/api/lessorcontract/renewlist/'+lessorcontractId,
        method: 'get'
    })
}

export function addObj(obj) {
    //alert("a");
  return request({
    url: '/api/lessorcontract/',
    method: 'post',
    data: obj
  })
}

export function getObj(lessorcontractId) {
  return request({
    url: '/api/lessorcontract/' + lessorcontractId,
    method: 'get'
  })
}

export function delObj(id) {
  return request({
    url: '/api/lessorcontract/' + id,
    method: 'delete'
  })
}

export function putObj(obj) {
    //alert(JSON.stringify(obj));
  return request({
    url: '/api/lessorcontract',
    method: 'put',
    data: obj
  })
}
export function getGenerateFeeObj(id) {
    return request({
        url: '/api/lessorcontract/generatefee-all/' + id,
        method: 'get'
    })
}

//改为待发送
export function presend(id) {
    return request({
        url: '/api/lessorcontract/presend/' + id,
        method: 'get'
    })
}

//改为已发送
export function send(id) {
    return request({
        url: '/api/lessorcontract/send/' + id,
        method: 'get'
    })
}


//文件上传
export function uploadContractFile(obj) {
    return request({
        url: '/admin/sys-file/upload',
        method: 'post',
        data:obj
    })
}
//保存PDFUrl
export function saveUrl(obj) {
    return request({
        url: '/api/lessorcontract/saveUrlAndContractNameById',
        method: 'post',
        data:obj
    })
}
//变更时记录历史
export function recordHis(id) {
    //alert(JSON.stringify(obj));
    return request({
        url: '/api/lessorcontract/record-his/'+id,
        method: 'put'
    })
}

//续签
export function renew(id) {
    //alert(JSON.stringify(id));
    return request({
        url: '/api/lessorcontract/renew/'+id,
        method: 'put',
    })
}

//退租
export function back(obj) {
    //alert(JSON.stringify(id));
    return request({
        url: '/api/lessorcontract/back',
        method: 'put',
        data: obj
    })
}



//退租记录
export function getContractBack(LessorContractId){
    //alert(contractId);
    return request({
        url: '/api/lessorcontractback/getbycontractid/'+LessorContractId,
        method: 'get'
    })
}

//审批记录
export function getContractApproveList(contractId){
    //alert(contractId);
    return request({
        url: '/api/commonapprovalrecord/'+contractId,
        method: 'get'
    })
}
//查看历史合同信息
export function getHistoryContract(LessorContractHisId){
    //alert(contractId);
    return request({
        url: '/api/lessorcontracthis/'+LessorContractHisId,
        method: 'get'
    })
}


//执行。从13改成03
export function excute(id) {
    //alert(JSON.stringify(id));
    return request({
        url: '/api/lessorcontract/excute/'+id,
        method: 'put',
    })

}




